package com.seanliao.nav.common.exception;


import com.seanliao.nav.common.enums.ResultCodeEnum;

/**
 * 事务异常
 *
 * @author Sean_Liao
 */
public class BusinessException extends RuntimeException {
    /**
     * 异常码
     */
    private final Integer code;

    public BusinessException() {
        super(ResultCodeEnum.FAIL.getMessage());
        this.code = ResultCodeEnum.FAIL.getCode();
    }

    public BusinessException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
    }

    public BusinessException(String message) {
        super(message);
        this.code = ResultCodeEnum.FAIL.getCode();
    }

    public BusinessException(int code, String message) {
        super(message);
        this.code = code;
    }

    public int getCode() {
        return code;
    }

}
